home *** CD-ROM | disk | FTP | other *** search
- Path: news.umbc.edu!not-for-mail
- From: schlein@umbc.edu (Jonas J. Schlein)
- Newsgroups: comp.lang.c
- Subject: Re: Help! Can't read input from keyboard!
- Date: 4 Apr 1996 14:17:47 -0500
- Organization: University of Maryland Baltimore County
- Message-ID: <4k178r$kse@umbc9.umbc.edu>
- References: <4jq0ts$5mh@taniemarie.solon.com>
- NNTP-Posting-Host: umbc9.umbc.edu
- NNTP-Posting-User: schlein
-
- Peter Seebach <seebs@taniemarie.solon.com> wrote:
- |> I guess I thought I knew C, but maybe not. The following program compiles
- |> without error with
-
- Maybe not ;-).
-
- |> gcc -g -O -Wa,ll -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes
-
- It does? Well even so since when is compiler acceptance equivalent to
- program correctness?
-
- |> but doesn't print 3! I thought scanf and printf were asymptotic.
-
- Asymptotic?
-
- |> #include <stdio.h>
- |>
- |> int main(void) {
- |> int i = 0;
- |>
- |> (void) sscanf, "3", "%d", i;
- |>
- |> (void) printf, "%d", i;
-
- It's customary to enclose arguments to a function in ()'s. Additionally
- the third argument to sscanf should be a pointer to int so put a & before
- that 'i'.
-
- |> return 0;
- |> }
- |>
- |> Can anyone help? I have cast sscanf() to void to prevent it from
- |> erroring.
-
- Only thing the void is doing is ignoring the return argument from those
- functions which aren't being invoked properly.
- --
- "If it wasn't for C, we would be using BASI, PASAL, and OBOL."
-
- Jonas J. Schlein (schlein@gl.umbc.edu)
-